<?php namespace Admin\Controller;

class WebsetController extends CommonController{
	public function index(){
		//实例化模型
		$webSetModel = new \Common\Model\Webset;
		$data = $webSetModel->get();
		View::with("data",$data);
		if(IS_POST){
		foreach ($_POST as $k => $v) {
		  $webSetModel->where("name",$k)->update(array("value"=>$v));
		  }
		}
		//写入配置文件
		//代码合法化
		$data = var_export($_POST,true);
		$data = "<?php return  ".$data."?>";
		file_put_contents("Config/webset.php", $data);
		View::make();
	}

}
